﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyServer.Common
{

    /// <summary>
    /// 表示该如何处理此次错误
    /// </summary>
    public enum ErrorOperate
    {
        /// <summary>
        /// 清除队列中所有数据包
        /// </summary>
        ClearQueue,
        /// <summary>
        /// 该错误已被妥善处理，队列不做操作继续执行
        /// </summary>
        Pass,
        /// <summary>
        /// 从队列中移除出错的数据包
        /// </summary>
        RemoveCol,
        /// <summary>
        /// 停止发送队列
        /// </summary>
        StopSend
    }

    /// <summary>
    /// 为错误捕捉事件提供数据存储
    /// </summary>
    public class ErrorCatchedEventArgs
    {
        /// <summary>
        /// 表示与事件绑定的错误
        /// </summary>
        public Exception Exception { get; private set; }
        /// <summary>
        /// 表示发生错误时操作的数据包
        /// </summary>
        public DataPackageCollection Pkg { get; private set; }
        /// <summary>
        /// 表示对此次错误该如何处理
        /// </summary>
        public ErrorOperate Operate{get;set;}
        /// <summary>
        /// 通过指定的错误与数据包构建对象实例
        /// </summary>
        /// <param name="ex"></param>
        /// <param name="pkg"></param>
        public ErrorCatchedEventArgs(Exception ex,DataPackageCollection pkg)
        {
            this.Exception = ex;
            this.Pkg = pkg;
        }
    }
}
